﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>配置中心</title>
    <script src="config_ui_dist/jquery-1.9.1.min.js"></script>
    <script src="config_ui_dist/jquery.json-editor.min.js"></script>
</head>
<body>
    <div id="jsonedit" style="width: 1000px; height: 500px; overflow-y: auto; border: 1px solid"></div>
    <input type="button" id="btnSave" value="保存配置" />
    <span id="jsontext" style="display: none">%(BodyContent)</span>
</body>
</html>
<script>
    $(function () {
        try {
            var json = JSON.parse($("#jsontext").text());
            var editor = new JsonEditor($("#jsonedit"), json);
            $("#btnSave").click(function () {
                var data = JSON.stringify(editor.get());
                $.ajax({
                    type: "post",
                    url: 'saveconfig',
                    async: false,
                    dataType: "json",
                    data: data,
                    success: function (res) {
                        alert("修改成功,请重启程序");
                    }
                });
            });
        }
        catch (e) {
            alert("JSON校验失败");
        }
    })
</script>